<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <button>href</button>
  <button>assign</button>
  <button>reload</button>

  <script>
        // var buttonEl = document.querySelector("button") as HTMLDivElement
    var buttonEl = document.querySelectorAll("button")
    buttonEl[0].onclick = function () {
      // console.log(window.location.href); // 获取当前的url
      location.href = "http://www.baidu.com"
    }
    buttonEl[1].onclick = function () {
      location.assign("http://www.baidu.com")
    }
    buttonEl[2].onclick = function () {
      location.replace("http://www.baidu.com")
    }
  </script>
</body>
</html>